﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Validity.Test
{
  [TestClass]
  public class ValidationResultTest
  {
    [TestMethod]
    public void TestWithRuleViolations()
    {
      var violations = new[] { new RuleViolation("My Violation") };
      var result = new ValidationResult(violations, "Description", "PropertyName");

      Assert.IsFalse(result.IsValid);
      Assert.AreEqual("Description", result.Description);
      Assert.AreEqual("PropertyName", result.PropertyName);
      Assert.AreSame(violations, result.RuleViolations);
    }

    [TestMethod]
    public void TestWithoutRuleViolations()
    {
      var violations = new RuleViolation[0];
      var result = new ValidationResult(violations, "Description", "PropertyName");

      Assert.IsTrue(result.IsValid);
      Assert.AreEqual("Description", result.Description);
      Assert.AreEqual("PropertyName", result.PropertyName);
      Assert.AreSame(violations, result.RuleViolations);
    }
  }
}
